<template>
  <div id="app">
    <router-view />
    <!-- 全局后台任务指示器 -->
    <GlobalBackgroundTasks />
    <!-- 开发环境下显示日志查看器 -->
    <LogViewer v-if="isDev" />
  </div>
</template>

<script setup>
import { onMounted, computed } from 'vue'
import { componentLogger } from '@/utils/logger'
import { useAppStore } from '@/stores/app'
import { useBackgroundTaskStore } from '@/stores/backgroundTask'
import GlobalBackgroundTasks from '@/components/GlobalBackgroundTasks.vue'
import LogViewer from '@/components/LogViewer.vue'

const appStore = useAppStore()
const backgroundTaskStore = useBackgroundTaskStore()
const isDev = computed(() => import.meta.env.DEV)

onMounted(() => {
  componentLogger.info('App component mounted')
  // 初始化应用
  appStore.init()
  
  // 恢复后台任务
  backgroundTaskStore.restoreFromLocalStorage()
  componentLogger.info('Background tasks restored')
})
</script>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#app {
  height: 100vh;
  background-color: #f5f5f5;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}
</style>
